import { createSlice } from "@reduxjs/toolkit";

interface BusinessType {
  businessId: number | null;
  info: any;
  isHomeShow: boolean;
  commodityId: number | null;
}

const initialState: BusinessType = {
  businessId: null,
  commodityId: null,
  isHomeShow: false,
  info: {},
};

const businessSlice = createSlice({
  name: "business",
  initialState,
  reducers: {
    setBusinessInfo(state, action) {
      state.businessId = action.payload.id;
      state.info = action.payload.info;
    },
    setHomeShow(state, action) {
      state.isHomeShow = action.payload;
    },
    setCommodityId(state, action) {
      state.commodityId = action.payload;
    },
  },
});

export default businessSlice.reducer;
export const { setBusinessInfo, setHomeShow, setCommodityId } =
  businessSlice.actions;
